package org.yunai.swjg.server.module.inventory;

import org.slf4j.Logger;
import org.springframework.stereotype.Service;
import org.yunai.swjg.server.entity.ItemEntity;
import org.yunai.swjg.server.module.inventory.item.Item;
import org.yunai.swjg.server.module.player.vo.Player;
import org.yunai.yfserver.common.LoggerFactory;

import javax.annotation.Resource;
import java.util.List;

/**
 * Inventory模块Service
 * User: yunai
 * Date: 13-4-6
 * Time: 下午2:44
 */
@Service
public class InventoryService {

    private static final Logger LOGGER_GAME = LoggerFactory.getLogger(LoggerFactory.Logger.game, InventoryService.class);

    @Resource
    private InventoryMapper inventoryMapper;

    // TODO 移到Inventory去
    public Inventory loadInventory(Player player) {
        Inventory inventory = new Inventory(player);
        List<ItemEntity> items = inventoryMapper.selectItemList(player.getId());
        for (ItemEntity entity : items) {
            Item item = Item.build(entity, player);
            inventory.putItem(item);
        }
        return inventory;
    }



}
